<?php
include_once 'parentPathConfig.php';
include_once $path . '/config.php';
include_once ROOT . '/utils/mysql_class.php';
include_once ROOT . '/models/System.php';
class SystemService {
	public function getSystem() {
		$sql = "select * from system";
		$result = mysql_query ( $sql );
		$row = mysql_fetch_array ( $result );
		if ($row) {
			$system = new System ();
			$system->setSiteName ( $row ['site_name'] );
			$system->setSiteDescpribt ( $row ['site_descript'] );
			$system->setSiteEmail ( $row ['site_email'] );
			$system->setSiteEmailPassword ( $row ['site_email_password'] );
			$system->setId ( $row ['id'] );
			$system->setPageSize ( $row ['page_size'] );
			$system->setSiteUrl ( $row ['siteUrl'] );
			return $system;
		} else {
			return null;
		}
	}
	public function updateSystem(System $system) {
		$sql = "update system set site_name='" . $system->getSiteName () . "',site_descript='" . $system->getSiteDescpribt () . "',site_email='" . $system->getSiteEmail () . "',site_email_password='" . $system->getSiteEmailPassword () . "',page_size='" . $system->getPageSize () . "',siteUrl='" . $system->getSiteUrl () . "' where id='" . $system->getId () . "'";
		$result = mysql_query ( $sql );
		if ($result) {
			return true;
		} else {
			return false;
		}
	
	}
}
?>